<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2024/12/17
  Time: 10:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <title>医院管理系统-管理员</title>
    <link rel="stylesheet" href="../../css/admin.css">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <header>
            <div class="header-content">
                <h1>医院管理系统</h1>
                <div class="user-info">
                    <span>欢迎, ${admin.name}管理员</span>
                    <a href="../../logout" class="logout-btn">
                        <i class="fas fa-sign-out-alt"></i> 退出登录
                    </a>
                </div>
            </div>
        </header>
        
        <div class="main-content">
            <nav class="sidebar">
                <ul>
                    <li>
                        <a href="javascript:void(0)" class="active" onclick="loadContent('doctor-manage')">
                            <i class="fas fa-user-md"></i> 医生管理
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" onclick="loadContent('ward-manage')">
                            <i class="fas fa-hospital"></i> 病房管理
                        </a>
                    </li>
                </ul>
            </nav>
            
            <div id="mainArea" class="content">
                <!-- 默认显示医生管理页面 -->
                <jsp:include page="doctor-manage.jsp" />
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        // 添加页面加载完成时的初始化
        $(document).ready(function() {
            initializeDoctorManage();
        });

        function loadContent(page) {
            // 更新侧边栏选中状态
            document.querySelectorAll('.sidebar a').forEach(link => {
                link.classList.remove('active');
            });
            event.target.closest('a').classList.add('active');
            
            // 使用Ajax加载对应的页面内容
            $.ajax({
                url: '/0201/pages/admin/' + page + '.jsp',
                success: function(response) {
                    $('#mainArea').html(response);
                    // 如果是医生管理页面，等待DOM加载完成后初始化
                    if (page === 'doctor-manage') {
                        $(document).ready(function() {
                            initializeDoctorManage();
                        });
                    }
                },
                error: function() {
                    alert('页面加载失败，请重试');
                }
            });
        }
    </script>
</body>
</html>
